package com.ly.cloud.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.plugins.Page;
import com.ly.cloud.dto.SystemSetDto;
import com.ly.cloud.entity.SystemSetPo;
import com.ly.cloud.entity.UserPo;
import com.ly.cloud.exception.CloudException;
import com.ly.cloud.exception.mapper.DBException;
import com.ly.cloud.mapper.SystemSetMapper;
import com.ly.cloud.service.SystemSetService;
import com.ly.cloud.vo.SystemSetVo;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;


@Service
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public class SystemSetServkceImpl implements SystemSetService {

	@Autowired
	private SystemSetMapper systemSetMapper;
	
	/**(non-Javadoc)
	 * Title: selectSystemSetList
	 * Description: 
	 * 根据参数名称查询系统设置
	 * Created On: 2018年12月6日
	 * @author LuHuaCong
	 * <p>
	 * @param page
	 * @param paraName
	 * @return  Page<SystemSetVo>
	 */
	@Override
	public Page<SystemSetVo> selectSystemSetList(Page<SystemSetVo> page, String paraName) {
		try {
			return page.setRecords(systemSetMapper.selectSysListByParaName(page, paraName));
		} catch (Exception e) {//注意，这里只是演示，实际情况请捕捉更加详细的异常，判断抛出详细的业务异常，不要将异常的代码直接抛出去了
			throw new CloudException("查询异常，请重试!", e);
		}
	}
	

	/**(non-Javadoc)
	 * Title: updateSysSetByparaCode
	 * Description: 
	 * 根据参数代码修改系统设置
	 * Created On: 2018年12月6日
	 * @author LuHuaCong
	 * <p>
	 * @param sysDto 实体
	 * @return boolean 是否更新成功
	 */
	@Override
	public boolean updateSysSetByparaCode(SystemSetDto sysDto) {
		Integer i = null;
		if(sysDto!=null) {
			try {
				i = systemSetMapper.updateSysSetByparaCode(sysDto);
				if(i>0) {
					return true;
				}else {
					return false;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return false;
	}

	


}
